﻿using System;
using NLog;
using NLog.Config;
using NLog.Targets;

namespace MyNLogTest
{
    class Program
    {
        private static Logger _logger = LogManager.GetCurrentClassLogger();

        static void Main(string[] args)
        {
            FileTarget target = LogManager.Configuration.FindTargetByName("logFileTarget") as FileTarget;
            target.FileName = "myFile.log";
            target.ArchiveFileName = "myFile.{#}.log";

            LoggingRule rule = LogManager.Configuration.LoggingRules[0];
#if !DEBUG
            rule.DisableLoggingForLevel(LogLevel.Debug);
#endif

            for (int i = 0; i < 1000; i++)
            {
                _logger.Trace("Sample trace message");
                _logger.Debug("Sample debug message");
                _logger.Info("Sample info message");
                _logger.Warn("Sample warn message");
                _logger.Error("Sample error message");
                _logger.Fatal("Sample fatal message");
            }

            Console.WriteLine("OK");
            Console.ReadLine();
        }
    }
}
